package com.kenyi.co.ui.home.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.util.Util;
import com.kenyi.co.GlideApp;
import com.kenyi.co.R;
import com.kenyi.co.ui.home.bean.SearchBean;
import com.kenyi.co.utils.ListBaseAdapter;
import com.kenyi.co.utils.SuperViewHolder;

/**
 * Created by Administrator on 2018/1/29.
 */

public class SearchAdapter extends ListBaseAdapter<SearchBean.DatasBean> {

    public SearchAdapter(Context context) {
        super(context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_right_item_2;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        SearchBean.DatasBean item = mDataList.get(position);
        final ImageView iv_item_vodeo = holder.getView(R.id.iv_item_vodeo);
        TextView tv_video_right_title = holder.getView(R.id.tv_video_right_title);
        TextView tv_video_right_sub_title = holder.getView(R.id.tv_video_right_sub_title);
        TextView tv_video_right_num = holder.getView(R.id.tv_video_right_num);
        TextView tv_video_right_time = holder.getView(R.id.tv_video_right_time);
        tv_video_right_time.setText(item.getVideoTime());
        tv_video_right_title.setText(item.getTitle());
        tv_video_right_sub_title.setText(item.getDesc());
        tv_video_right_num.setText("播放次数：" + item.getReadCount() + "次");
        try {
            if (Util.isOnMainThread() && mContext != null) {
                GlideApp.with(mContext)
                        .load(item.getVideoImg())

                        .placeholder(R.drawable.iv_bg_video_right)
                        .error(R.drawable.iv_bg_video_right)
                        .into(iv_item_vodeo);
            }

        } catch (Exception e) {

        }


    }


}
